Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Want to a "if button is pressed for 3 seconds" pronto script.
This thread has 13 replies. Displaying all posts.
Post 1 made on Sunday May 4, 2014 at 20:15
King of typos
Loyal Member
Joined:
Posts:
June 2002
5,281
Hey there folks, I've had my 9400 for a couple of years now and I would like a simple PS.

Currently I have the Power button set globally to jump to a power page. One of which contains every component's power states. Either an On or Off button or Power Toggle.

The main point of having the power button to go to the Power Page is so that the rest of the family would know what to do. Right now it would just go to the Power Page with out any IR being sent.

My thought is to continue to have that done when just pressed and let go. However, if it's pressed and held for 3 or more seconds. Then I would like for it to execute the same process as what the Off button is on my AVR. Which is just to send an IR code to my AVR, then jump to the Main Home page for the next time use.

Would this even be possible? I recall seeing someone who was able to make a PS for the jog dial. Where if the user made it one click at a time, that the IR sent was a song skip. But if 2 or more clicks were made with in a second, the IR would be a Fast Forward/Reverse type of IR. Although that was a couple of years ago that I saw it, and I wouldn't be able to find it again.

Thanks from a long time member.

KOT
Post 2 made on Sunday May 4, 2014 at 23:23
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Rob,

Here you go.

[Link: remotecentral.com]

To execute the action list of the same button containing the script from inside the onHold or onRelease (if you put the action in onHold, then you don't need it in onRelease nor do you need onRelease), use

this.executeActions();

or

this.scheduleActions();

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Monday May 5, 2014 at 00:02
King of typos
Loyal Member
Joined:
Posts:
June 2002
5,281
Thank you for your reply Lyndel. I've read it over and all of it went over my head.

I have copied and pasted the following script...

// Count how many seconds the power button has been pressed

var counter = 0;

onHold = function()
{
counter++;
if (counter==2)
{
AllOff()
}
};
onHoldInterval = 1000;

onRelease = function()
{
CF.widget("TV_OFF","JUMPTO", "RESOURCES").executeActions();
};

But I am at a lost on what I would need to modify for my set up. I assumed that I would want to change RESOURCES to HOME PAGE. As the main screen(for next time use) is labeled Home Page. Not sure if capitalization matters either.

I am by no means a programmer, I am the one who repairs the hardware. lol

If it would help. The page that contains the power functions is labeled "Power Page". This is the page that it goes to currently when the button is pressed and released. Once there, if the user were to press the AVR off button, it will then go through a series of pages and end up at the "Home Page" for the next use.

KOT
Post 4 made on Tuesday May 6, 2014 at 00:25
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
If this is a PEP2 config, email it to me please. If PEP3, note that I can rework it to view in PEP2 and then send you back a PEP2 config which you can use as an example. May be this weekend before I can get to it but I will have a look.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 5 made on Wednesday May 7, 2014 at 12:13
King of typos
Loyal Member
Joined:
Posts:
June 2002
5,281
Hey there Lyndel,
Just to let you know, I've sent you a PM with my email and such. Not sure if you have received it or not.

Thanks,
KOT
Post 6 made on Thursday May 8, 2014 at 19:36
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Sorry, was not checking PM here lately as had a hard disk crash and rebuilding.

Send me an email to my addy on profile.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 7 made on Friday May 9, 2014 at 12:07
King of typos
Loyal Member
Joined:
Posts:
June 2002
5,281
Ok, sent an email to you.

KOT
Post 8 made on Saturday May 10, 2014 at 11:25
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Reply with working config sent.

Once appropriate ProntoScript names were assigned, the following script was put into the 'Power' button on the System Page.

var intervalms = 1000;
var counter = 0;
var threshold = 3; // 3 executions of 1000ms
var executeReleaseActions = true;

onHold=function()
{
System.print('Counter: ' + counter);
counter = counter + 1;
if (counter >= threshold)
{
// set boolean so that onRelease does not do Jump.
executeReleaseActions = false;
// clear holdInterval so only reach threshold 1 time
this.onHoldInterval = 0;
var w = CF.widget('AVR_OFF', 'POWER', 'HOME');
System.print('ThresholdMet w: ' + w);
if (w != null)
{
// instead of this try/catch block with executeActions, if using newer firmware, can also call
// w.scheduleActions
try
{
w.executeActions();
}
catch(e)
{
System.print('Err. e:' + e)
Diagnostics.log('Err. e:' + e);
}
}
}
}

onRelease = function ()
{
if (executeReleaseActions)
{
// instead of this try/catch block with executeActions, if using newer firmware, can also call
// this.scheduleActions
try
{
this.executeActions();
}
catch(e)
{
System.print('Err. e:' + e)
Diagnostics.log('Err. e:' + e);
}
}
}

onHoldInterval = intervalms;

Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 9 made on Sunday May 11, 2014 at 01:25
King of typos
Loyal Member
Joined:
Posts:
June 2002
5,281
Thank you, this works great.

I am assuming that if I wanted to change the hold down time, I just have to change the 3's in the following script line... var threshold = 3; // 3 executions of 1000ms

KOT
Post 10 made on Sunday May 11, 2014 at 14:35
Lowpro
Select Member
Joined:
Posts:
March 2004
2,081
On May 11, 2014 at 01:25, King of typos said...
Thank you, this works great.

I am assuming that if I wanted to change the hold down time, I just have to change the 3's in the following script line... var threshold = 3; // 3 executions of 1000ms

KOT

Give it a try and you will learn the answer.
LP Related Links:
View my profile to access various
links to key posts and downloads.
Post 11 made on Sunday May 11, 2014 at 16:20
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Yes. There are actually 2 ways to affect the change. You could change the 3 to a 6 and then change the line that says onHoldInterval=500;

The threshold times the interval is the actual number of milliseconds that you want to trigger the 'threshold' so to speak. One the counter hits the threshold, then the held action will indeed trigger.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 12 made on Saturday May 31, 2014 at 12:30
King of typos
Loyal Member
Joined:
Posts:
June 2002
5,281
I have an other problem. I am trying to modify the above script to accept a second "power off" command. The reasoning is because when my AVR is on the internet/iPod source, it tends to go into it's own little world and not accept the 1st IR command. Thus when I press and hold the button, it never shuts off.

Here's what I've done.
I've gone into my AVR's activity panel and added "AVR_PWR_OFF" to the power off button.
After that, I've added 'AVR_PWR_OFF' to the following line...

var w = CF.widget('AVR_OFF', 'POWER', 'AVR_PWR_OFF', 'HOME');

No matter what order I put it, it just nulls the entire script. I can press and hold the button and nothing happens. I even tried to put a second "AVR_OFF" and removed the AVR_PWR_OFF. Still, nothing happens.

I can't see where there's a value that I have to change to make a 4th command. Thinking that was my problem, but I suppose not.

Thank you,
KOT
Post 13 made on Saturday May 31, 2014 at 17:03
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
To understand what happened when you made your change, I recommend you have a look at the ProntoScript Dev Guide. CF.widget() function does not accept 4 parameters which is what you have supplied.

var w = CF.widget('AVR_OFF', 'POWER', 'AVR_PWR_OFF', 'HOME');

The way you have this coded, the script is looking for an activity with the ProntoScript Name 'AVR_PWR_OFF'.

Whenever I encounter something like this, I ask myself, can I solve the problem without script changes. In your case, I suspect the answer is a resounding 'Yes!!!'.

My recommendation is that everywhere you want to send discrete power off to AVR, send the IR code 2 times by simply adding another IR code to the button's action list. Won't hurt anything to send the discrete power off 2 times.

Last edited by Lyndel McGee on May 31, 2014 17:10.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 14 made on Monday June 2, 2014 at 05:34
King of typos
Loyal Member
Joined:
Posts:
June 2002
5,281
I actually discovered that the power off command is the only command that can be seen with only one "press".

Before you helped me out. I had selected buttons in the "Internet" activity set to transmit a dummy code that the AVR would wake up to. This included the hard power button, which only jumped to the power page. When I originally made the project, I didn't know the power off could be seen with out a wake up.

Now that I do know this. I just made that hard power button as a system wide so your PS can be used. It's working, so I'm happy.

I'll look for that guide and read some of it.

Thanks again,
KOT


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse